package com.yupi.yuoj.judge;

import com.yupi.yuoj.judge.codesandbox.strategy.DefaultJudgeStrategy;
import com.yupi.yuoj.judge.codesandbox.strategy.JavaJudgeStrategy;
import com.yupi.yuoj.judge.codesandbox.strategy.JudgeContext;
import com.yupi.yuoj.judge.codesandbox.strategy.JudgeStrategy;
import com.yupi.yuoj.judge.codesandbox.model.JudgeInfo;
import com.yupi.yuoj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @author 86134
 * @version 1.0
 * @description TODO
 * @date 2024/6/25 18:12
 */
@Service
public class JudgeManager {

    public JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if("java".equals(language)){
            judgeStrategy = new JavaJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
